package com.lmc.gobang.config;

import com.lmc.gobang.model.Result;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Select;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
@Slf4j
@ResponseBody
@ControllerAdvice
public class ErrorHandle {

    @ExceptionHandler()
    public Result handle(Exception e) {

        return Result.fail(e.getMessage());
    }

    @ExceptionHandler()
    public Result handle(org.springframework.dao.DuplicateKeyException e) {

        return Result.fail("用户名已重复");
    }

}
